--[[/**
-- * 
 * 对应的召唤物死亡时, 召唤一个低级

-- */]]

---@class BuffEffect216400 : BaseBuffEffect
BuffEffect216400 = ClientFight.CreateClass("BuffEffect216400", ClientFight.BaseBuffEffect)
local t = BuffEffect216400

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    if (parameters[1]) then
    else
        return IBuffEffect.FAIL;
    end
    local summon = parameters[1];
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    if (summon.summonId ~= buffEffectValue[1]) then
        return IBuffEffect.FAIL;
    end
    local triggerSkillId = 0;
    for i = 2, i < table.getn(buffEffectValue), 2 do
        local skillId = buffEffectValue[i];
        local buffId = buffEffectValue[i + 1];
        if (containsSkillId(skillId, buff.source)) then
            triggerSkillId = buffId;
            break ;
        end
    end
    if (triggerSkillId == 0) then
        return IBuffEffect.FAIL;
    end
    ClientFight.BaseBuffEffect.triggerSkill(self, fight, buff.source, nil, triggerSkillId);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

function t:containsSkillId(skillId, source)
    local skills = source.skills;
    for k, skill in pairs(skills) do
        if (skill.skillId == skillId) then
            return true;
        end
    end
    local passiveskills = source.passiveskills;
    for k, skill in pairs(passiveskills) do
        if (skill.skillId == skillId) then
            return true;
        end
    end
    return false;
end

t.New()